package com.wjz.admin.aop;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: API Interceptor
 * @Author: jzq
 * @Create: 2022/1/4
 */
@Slf4j
@Component
public class ApiInterceptor implements HandlerInterceptor {


    /**
     * controller 执行之前调用
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        String uri = request.getRequestURI();
        log.info("Access uri: {}", uri);

        return true;
    }

    /**
     * controller 执行之后，且页面渲染之前调用
     */
    /*
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {
        System.out.println("------postHandle-----");
    }
    */


}
